package com.polaris.live.adapter

import android.view.View
import com.bumptech.glide.Glide
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterLoginRewardBinding
import com.polaris.live.resp.back_resp.UserReward
import com.polaris.live.utils.image.ImageUtils

/**
 * LoginRewardAdapter
 *
 * @author Created by 天晴 on 2024/11/12/016 20:29
 */
class LoginRewardAdapter : BaseBindingAdapter<AdapterLoginRewardBinding, UserReward>() {

    override fun convert(holder: VBViewHolder<AdapterLoginRewardBinding>, item: UserReward) {
        holder.vb.apply {
            rewardName.text = item.displayText
            Glide.with(rewardImg.context).load(ImageUtils.imgPath(item.icon))
                .into(rewardImg)
            rewardCount.text = item.text
            if (item.locked == true) {
                rewardLocked.visibility = View.VISIBLE
                rewardImg.alpha = 0.7f
            } else {
                rewardLocked.visibility = View.GONE
                rewardImg.alpha = 1f
            }
        }
    }

    fun setSelect(position: Int): UserReward {
        return data[position]
    }

}